@glodon-aiot/agent-cli-ui 3.26.0-alpha.13 → 3.26.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.mjs +4 -4
- package/dist/lib/index.js +1 -1
- package/package.json +4 -4
package/dist/es/index.mjs
CHANGED
|
@@ -6503,7 +6503,7 @@ const Uu = We((M, e) => {
|
|
|
6503
6503
|
})]
|
|
6504
6504
|
})
|
|
6505
6505
|
});
|
|
6506
|
-
}), bu = "@glodon-aiot/agent-cli-ui", vu = "3.26.0-alpha.
|
|
6506
|
+
}), bu = "@glodon-aiot/agent-cli-ui", vu = "3.26.0-alpha.14", Gu = "./dist/es/index.mjs", Pu = "./dist/lib/index.js", Wu = "./dist/src/index.d.ts", Ru = {
|
|
6507
6507
|
import: "./dist/es/index.mjs",
|
|
6508
6508
|
require: "./dist/lib/index.js",
|
|
6509
6509
|
types: "./dist/src/index.d.ts"
|
|
@@ -6525,9 +6525,9 @@ const Uu = We((M, e) => {
|
|
|
6525
6525
|
commit: "cz"
|
|
6526
6526
|
}, Hu = {
|
|
6527
6527
|
"@ant-design/icons": "^5.3.4",
|
|
6528
|
-
"@glodon-aiot/apis": "^3.26.0-alpha.
|
|
6529
|
-
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.
|
|
6530
|
-
"@glodon-aiot/react-components": "^3.26.0-alpha.
|
|
6528
|
+
"@glodon-aiot/apis": "^3.26.0-alpha.14",
|
|
6529
|
+
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.14",
|
|
6530
|
+
"@glodon-aiot/react-components": "^3.26.0-alpha.14",
|
|
6531
6531
|
"@matejmazur/react-mathjax": "^0.1.10",
|
|
6532
6532
|
"@react-pdf-viewer/core": "^3.12.0",
|
|
6533
6533
|
"@react-pdf-viewer/default-layout": "^3.12.0",
|
package/dist/lib/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
${j}`:j}if(e&&e.length>0){const s=e.filter(Boolean).map(D=>``).join(`
|
|
14
14
|
`);j=s?`${s}
|
|
15
15
|
${j}`:j}}return j},Tu=M=>{const e=Math.floor(M/3600),N=Math.floor(M%3600/60),t=M%60,j=s=>String(s).padStart(2,"0");return`${j(e)}:${j(N)}:${j(t)}`},cu=z.forwardRef((M,e)=>{var Hj,Vj,Xj,$j,Kj,qj,Mi,ei,Ni,ti,ji,ii,si,Di,zi,gi;const{application:N,docViewerUrl:t="",currentSession:j,onCreateSession:s,embeddingService:D,setCurrentSession:g,networkStatus:u,setNetworkStatus:n}=M,[I,A]=z.useState([]),[r,L]=z.useState([]),[T,y]=z.useState(!1),[C,O]=z.useState(null),w=z.useRef(0),[m,h]=z.useState(),[k,W]=z.useState(),R=z.useRef(null),MM=z.useRef(!0),Y=z.useRef(!1),eM=z.useRef(!1),{service:b,agentClient:p,depId:G,footer:J,transform:Q,defaultInput:gM,onMessage:QM,onHistoryLoad:oM,beforeMessageSend:yM,bodyStyle:ZM,disabled:TM,features:S,popupContainer:d,icon:$,sider:dM,mode:mM,silencedSeconds:XM,localFilesUI:K,localFilesApprovalBridge:wM}=z.useContext(JM),CM=N.type===B.ApplicationTypes.Agent&&K?p==null?void 0:p.localWorkspace:void 0,[tM]=Jg(CM),l=xe.useMemoizedFn(()=>(d==null?void 0:d.current)||document.body),[F,V]=z.useState(!1),f=z.useRef(I),uM=z.useRef(void 0),x=z.useRef(new Set),[Z,_]=z.useState(0),[cM,sM]=z.useState([]),[q,YM]=z.useState([]),[PM,UM]=z.useState(0),[$M,uN]=z.useState(!1);z.useEffect(()=>{uN(PM>0)},[PM]);const bM=z.useRef(null),[pM,Ne]=z.useState([]),[KM,le]=z.useState(!1),[IN,ID]=z.useState(!1),[nD,TD]=z.useState(""),[cD,$e]=z.useState(),[Ke,nN]=z.useState({}),TN=z.useRef(null),Yj=z.useRef(null),At=z.useRef(null),[wj,aD]=z.useState(!1),[rD,LD]=z.useState([]),[AD,UN]=z.useState(!0),[yD,oD]=z.useState(!0),[Ej,re]=z.useState(!1),[yt,Ce]=z.useState(!1),[lD,ot]=z.useState(!1),[ue,cN]=z.useState(typeof(S==null?void 0:S.promptVariables)=="object"?S.promptVariables.default||[]:[]),[CD,dD]=z.useState(()=>{const c=typeof(S==null?void 0:S.knowledges)=="object"&&S.knowledges.default||void 0;if(c){if(Array.isArray(c)&&c.some(v=>Array.isArray(v.fileIds)&&v.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(qN(c)>be)throw Error(`knowledges and fileIds total count cannot exceed ${be}`)}return c}),[hj,Re]=z.useState(!1),[Qj,aN]=z.useState(!1),[OD,rN]=z.useState(typeof(S==null?void 0:S.connectNetwork)=="object"&&typeof(S==null?void 0:S.connectNetwork.default)=="boolean"?S.connectNetwork.default:!1),[Sj,pN]=z.useState(!1),[xD,fe]=z.useState(!1),[YD,wD]=z.useState(null),[bN,We]=z.useState(!1),[mj,fj]=z.useState(!1),{isSwitchingToExistingSession:kj,setIsSwitchingToExistingSession:vN}=Nj(),qe=z.useRef(null),[lt,ED]=z.useState("");z.useEffect(()=>{if(!XM)return;let c=Tu(XM);ED(c)},[XM]);const LN=Tg((Hj=S==null?void 0:S.botMessageBox)==null?void 0:Hj.artifacts),GN=LN.visible,Ct=xe.useMemoizedFn(c=>IM(exports,null,function*(){var P,jM,NM;if(!GN)return;const o=j,E=c||((P=o==null?void 0:o.data)==null?void 0:P.id);if(!o||!E||((jM=o.data)==null?void 0:jM.id)!==E)return;const v=++w.current;try{const SM=yield o.getArtifacts();if(v!==w.current||((NM=j==null?void 0:j.data)==null?void 0:NM.id)!==E)return;L(SM||[])}catch(SM){}}));z.useEffect(()=>{if(wD(j),j===null)fe(!1);else if(j===void 0)fe(!0);else{if(YD===null){if(kj){fe(!0),vN(!1);return}fe(!1);return}j.ready?fe(!1):fe(!0)}},[j,j==null?void 0:j.ready,kj]);const[dt,hD]=z.useState(null),Uj=z.useRef(null);z.useEffect(()=>{var c;hD((c=d==null?void 0:d.current)!=null?c:null)},[d]),z.useEffect(()=>{C&&y(!0)},[C]),z.useEffect(()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;w.current+=1,L([]),y(!1),O(null),c&&GN&&Ct(c)},[(Vj=j==null?void 0:j.data)==null?void 0:Vj.id,GN]),z.useEffect(()=>{var E,v;j&&(f.current=[]),A([]),MM.current=!0,Y.current=!1;const c=R.current;if(c&&c.scrollTo({top:0}),!((E=j==null?void 0:j.data)!=null&&E.id))return;if(Ce(!1),re(!1),(v=j.messages)!=null&&v.length){const jM=[...j.messages.filter(NM=>NM==null?void 0:NM.messageId)].reverse();f.current=[...jM],A([...jM]),fe(!1)}const o=P=>{var jM;(jM=j==null?void 0:j.data)!=null&&jM.id&&(f.current=[...P].reverse(),A([...P].reverse()),!P||P.length<10?aN(!1):aN(!0),fe(!1),oM&&oM({applicationId:N.id,sessionId:j.data.id,histories:P}))};return j.addEventListener("history:loaded",o),()=>{f.current=[],A([]),j==null||j.removeEventListener("history:loaded",o)}},[j]),z.useEffect(()=>{const c=()=>{var o;(o=j==null?void 0:j.data)!=null&&o.id&&(j.promptVariables&&cN(j.promptVariables.sort((E,v)=>E.key.localeCompare(v.key))),j.knowledges&&dD(j.knowledges),n(j.netOpen))};return j==null||j.addEventListener("data:updated",c),()=>{j==null||j.removeEventListener("data:updated",c)}},[j]),z.useEffect(()=>{var o;if(!((o=j==null?void 0:j.data)!=null&&o.id))return;const c=E=>{var v;console.error(E.message,E.cause,"e.case"),a.notification.config({getContainer:()=>(d==null?void 0:d.current)||document.body,prefixCls:"gbot-notification"}),a.notification.error({message:((v=E.cause)==null?void 0:v.message)||E.message}),a.notification.config({getContainer:void 0,prefixCls:"gbot-notification"})};return j.addEventListener("error",c),()=>{j==null||j.removeEventListener("error",c)}},[j]);const QD=()=>{var E;if(!((E=j==null?void 0:j.data)!=null&&E.id)||!(N!=null&&N.id))return;const c=j.data.id,o=I[I.length-1];if(o&&o.isContext){te("success","已开启新话题");return}else j.clear().then(()=>{const v=new _e("",c,B.IHistoryRole.System);v.isContext=!0,A([v,...I])})};z.useEffect(()=>{N!=null&&N.id&&(b==null||b.getRecommendQues(N.id).then(c=>{Ne(c)}))},[G,N]);const Ot=c=>IM(exports,null,function*(){var qM,aM;if(TM)return te("error","发送功能被禁用"),!1;const o=c||m;if(!(o!=null&&o.trim()))return te("error","请输入你想问的"),!1;if(!(ue==null?void 0:ue.every(RM=>!!(RM!=null&&RM.value)))){if(Q!=null&&Q.promptVariables)return te("error","变量值不能为空"),!1;console.error("变量值不能为空",ue==null?void 0:ue.map(RM=>!!(RM!=null&&RM.value)))}if(yt)return te("error","正在回复中"),!1;if(F)return te("error","等待初始化"),!1;if(!AD)return te("error","正在解析文件"),!1;if($M)return te("error","正在上传图片"),!1;sM([]),YM([]);const v=(qM=j==null?void 0:j.data)==null?void 0:qM.id;if(!v)return bN?!1:(We(!0),s==null||s({netOpen:u?Ue.OPEN:Ue.CLOSE}).then(RM=>{var nM,FM;Re(!0),n(!!((nM=RM.data)!=null&&nM.netOpen)),rN(!!((FM=RM.data)!=null&&FM.enableNetOpen)),xt(RM).then(()=>{g==null||g(RM),Re(!1),W(o)})}).catch(RM=>{We(!1)}),!0);if(bN)return!1;We(!0),pN(!0);const P=kt(o,q,Ke[v],(N==null?void 0:N.type)||0);let jM;try{yM?jM=yield yM==null?void 0:yM({applicationId:N.id,sessionId:v,message:{content:P,sessionId:v,role:B.ChatMessageRole.User,files:Ke[v]}}):jM=!0}catch(RM){jM=!1}if(pN(!1),jM===!1)return We(!1),!1;let NM=o;typeof jM=="object"&&(NM=jM.content||o);const fM=yield(()=>new Promise(RM=>{cN(nM=>(RM(nM),nM))}))();return(yield j.setPromptVariables(fM))?(((aM=Ke[v])==null?void 0:aM.length)>0?yield SD(NM):yield Yt(NM),!0):(We(!1),!1)}),xt=c=>new Promise((o,E)=>IM(exports,null,function*(){const jM=(c==null?void 0:c.promptVariables).filter(NM=>NM.type?!((NM.type===B.PromptVariableType.User||NM.type===void 0)&&NM.key==="query")&&!((NM.type===B.PromptVariableType.System||NM.type===void 0)&&NM.key==="datetime"):NM.key!=="query").map(NM=>{var fM;const SM=(fM=ue.find(iM=>iM.key===NM.key&&iM.type===NM.type))==null?void 0:fM.value;return NM.value=SM||"",NM});cN(jM.sort((NM,SM)=>NM.key.localeCompare(SM.key))),yield c==null?void 0:c.setPromptVariables(jM).catch(NM=>{console.error(NM),te("error",NM.message)}),o()})),SD=c=>{var P,jM,NM;if(UN(!1),!((P=j==null?void 0:j.data)!=null&&P.id)||!(N!=null&&N.id))return;const o=((jM=j.data)==null?void 0:jM.id)||"";let E=[],v=new Set;return(NM=Ke[o])==null||NM.forEach(SM=>{v.has(SM.id)||(E.push(SM),v.add(SM.id))}),UN(!0),Yt(c,E)};z.useEffect(()=>{if(!k||!j)return;const c=k,o=()=>IM(exports,null,function*(){pN(!0);const E=kt(c,q,Ke[j.id],(N==null?void 0:N.type)||0);let v;try{yM?v=yield yM==null?void 0:yM({applicationId:N.id,sessionId:j.id,message:{content:E,sessionId:j.id,role:B.ChatMessageRole.User,files:Ke[j.id]}}):v=!0}catch(P){v=!1}if(pN(!1),v===!1){We(!1);return}Yt(c),W(void 0)});return j.ready?o():j.addEventListener("ready",o,!0),()=>{j==null||j.removeEventListener("ready",o)}},[k,j]);const Yt=(c,o)=>IM(exports,null,function*(){var qM,aM,RM;const E=(qM=j==null?void 0:j.data)==null?void 0:qM.id;if(!E)return;Ce(!0),re(!0);const v=kt(c,q,o,(N==null?void 0:N.type)||0);let P;if(N.type===B.ApplicationTypes.Agent)P=void 0;else if(N.type===B.ApplicationTypes.Dialog&&((aM=N.arrange)!=null&&aM.length)&&N.arrange[0].visionOpen){const nM=q&&q.length?q.filter(Boolean):[];P=nM.length?nM:void 0}else P=void 0;const jM=new _e(v,E,B.IHistoryRole.User,o,P);h(void 0),$e(void 0),f.current=[jM,...I],A(f.current),N.id&&QM&&QM({applicationId:N.id,sessionId:E,message:jM});const NM=new _e("",E,B.IHistoryRole.System);NM.isWaiting=!0,f.current=[NM,...f.current],A(f.current);const SM=(o==null?void 0:o.filter(nM=>!nM.localAttachment).map(nM=>nM.id))||[],fM={stream:pe.configuration.stream,referenceFirst:!1};if(Q!=null&&Q.promptVariables){const nM=ue==null?void 0:ue.reduce((FM,ke)=>(FM[ke.key]=ke.value,FM),{});fM.formatValues=nM}if(Q!=null&&Q.knowledges){const nM=CD;fM.knowledges=nM}const iM={text:v,fileIds:SM,files:o,uuid:jM.messageId};P&&P.length>0&&(iM.imageContent=P),j.ready||(yield new Promise(nM=>{j.addEventListener("ready",()=>nM(),!0)})),yield j.send(iM,fM),nN({[E]:[]}),(RM=TN.current)==null||RM.update({keepLocalAttachments:!1}),sM([]),YM([]),We(!1)});z.useEffect(()=>{var fM;const c=(fM=j==null?void 0:j.data)==null?void 0:fM.id;if(!c)return;let o=null,E=null,v="";const P=()=>{o=null,E&&(A([E,...f.current]),E=null)},jM=()=>{o!==null&&(cancelAnimationFrame(o),o=null,E=null)},NM=iM=>{if(!iM.sessionId||iM.sessionId&&iM.sessionId!==uM.current)return;if(iM.role===B.IHistoryRole.User){if(f.current.some(AN=>AN.messageId&&AN.messageId===iM.messageId))return;const FM=new _e(iM.content,c,B.IHistoryRole.User,iM.files,iM.imageContent);FM.messageId=iM.messageId||FM.messageId,FM.renderKey=FM.messageId;const ke=new _e("",c,B.IHistoryRole.System);ke.isWaiting=!0,f.current=f.current.filter(AN=>!AN.isWaiting),f.current=[ke,FM,...f.current],A(f.current),re(!0),Ce(!0),N.id&&QM&&QM({applicationId:N.id,sessionId:c,message:FM});return}if(iM.index===-1&&iM.code!==200&&iM.code!==11915&&iM.code!==11916&&(jM(),re(!1),Ce(!1),f.current=f.current.filter(nM=>!nM.isWaiting),A([...f.current]),f.current=[...f.current],iM.content)){a.notification.config({getContainer:()=>(d==null?void 0:d.current)||document.body,prefixCls:"gbot-notification"}),a.notification.error({message:iM.content}),a.notification.config({getContainer:void 0,prefixCls:"gbot-notification"});return}const qM=iM.actions||[],aM=new _e(iM.content,c,B.IHistoryRole.Robot);aM.reasoningContent=iM.reasoningContent,aM.searchReference=iM.searchReference,aM.thinkingSecs=iM.thinkingSecs,aM.thinkingStatus=iM.thinkingStatus,aM.actions=qM,aM.isLoading=!0,aM.searchingStatus=iM.searchingStatus;const RM=f.current.some(nM=>nM.isWaiting);if(f.current=f.current.filter(nM=>!nM.isWaiting).filter(nM=>!nM.isReplying),RM&&(v=""),aM.renderKey=v||iM.messageId||aM.messageId,v=aM.renderKey,aM.messageId=iM.messageId||aM.renderKey,iM.index===void 0){E=aM,o===null&&(o=requestAnimationFrame(P));return}if(jM(),(iM.code===11915||iM.code===11916)&&(re(!1),Ce(!1),aM.isLoading=!1,aM.content=iM.code===11916?"尊敬的用户您好,让我们换个话题再聊聊吧。":"请您换个问题问我吧~",aM.isSensitive=!0,A([aM,...f.current])),iM.index===-2&&(re(!1),Ce(!1),aM.isLoading=!1,aM.content="回答已中止~",aM.isSuspend=!0,A([aM,...f.current]),Ct(c)),iM.index===-1&&(re(!1),Ce(!1),aM.isLoading=!1,aM.reference=iM.reference,A([aM,...f.current]),iM.code===200&&Ct(c),N.id)){const nM=aM.messageId;x.current.has(nM)||(x.current.add(nM),QM&&QM({applicationId:N.id,sessionId:c,message:aM}))}iM.index===-3&&(re(!1),Ce(!1),aM.isLoading=!1,aM.reference=iM.reference,aM.relatedQuesion=iM.relatedQuesion,A([aM,...f.current]))},SM=()=>{j.addEventListener("message:updated",NM)};return j.ready?j.addEventListener("message:updated",NM):j.addEventListener("ready",SM),()=>{jM(),j==null||j.removeEventListener("message:updated",NM),j==null||j.removeEventListener("ready",SM)}},[j]),z.useEffect(()=>{if(!j){V(!1);return}const c=o=>{V(o)};return V(j.frozen),j.addEventListener("frozen",c),()=>{j==null||j.removeEventListener("frozen",c)}},[j]),z.useEffect(()=>{if(!p)return;const c=p.questionContextMaxLength||4e3;_(c)},[p,b]),z.useEffect(()=>{gM&&$e(gM.text)},[gM]);const te=(c,o,E)=>{ie(d,()=>{a.message.open({type:c,content:o,key:E})})},pj=c=>{const o=c.size;return o<=0?(te("error","该文件为空,请重新上传"),!1):o>ft*KN?(te("error",`图片须小于${ft}M`),!1):(sM(E=>E.length>=Be?(te("warning",`图片最多上传${Be}张`),E):[...E,c]),!1)},mD=()=>{var c;return(N.type===B.ApplicationTypes.Agent&&(Q==null?void 0:Q.imageUpload)||N.type===B.ApplicationTypes.Dialog&&((c=N.arrange)==null?void 0:c.length)&&!!N.arrange[0].visionOpen&&(Q==null?void 0:Q.imageUpload))&&!TM},fD=()=>!!D&&(Q==null?void 0:Q.fileUpload)&&(N==null?void 0:N.id)&&!TM,bj=c=>{var aM,RM;const o=Array.from(c||[]).filter(Boolean);if(!o.length)return;const E=mD(),v=fD(),P=[],jM=[];let NM=0,SM=0,fM=0;o.forEach(nM=>{var ui,Ii,ni;const FM=(Ii=(ui=nM.name)==null?void 0:ui.split(".").pop())==null?void 0:Ii.toLowerCase();if(ts(nM)){v&&N.type===B.ApplicationTypes.Agent?jM.push(nM):fM++;return}if(((ni=nM.type)==null?void 0:ni.startsWith("image/"))||!!Ai(nM.name)){E?P.push(nM):NM++;return}if(es.includes(nM.type)||["pdf","doc","docx"].includes(FM||"")){v?jM.push(nM):SM++;return}fM++});const iM=[],qM=NM+SM+fM;if(!v&&!E)qM&&iM.push(`当前不支持上传文件/图片,已忽略${qM}个文件`);else if(v&&!E){const nM=NM+fM;if(nM){const FM=N.type===B.ApplicationTypes.Agent?".doc/.docx/.pdf/.xls/.xlsx/.svg/.dwg/.json":".doc/.docx/.pdf";iM.push(`仅支持上传 ${FM} 文件,已忽略${nM}个其他类型文件`)}}else if(!v&&E){const nM=SM+fM;nM&&iM.push(`仅支持上传图片(.jpg/.jpeg/.png/.bmp),已忽略${nM}个其他类型文件`)}else fM&&iM.push(`存在不支持的文件类型,已忽略${fM}个文件`);if(iM.length&&te("warning",iM.join(";"),"precheck-warn"),P.length){const nM=Math.max(0,Be-cM.length),FM=P.slice(0,nM);FM.forEach(ke=>pj(ke)),P.length>FM.length&&te("warning",`最多上传${Be}张图片`)}jM.length&&((RM=(aM=TN.current)==null?void 0:aM.appendFiles)==null||RM.call(aM,jM))},vj=c=>{var E;const o=(E=c.clipboardData)==null?void 0:E.files;o&&o.length&&(c.preventDefault(),c.stopPropagation(),bj(o))},Gj=c=>{c.preventDefault()},Pj=c=>{var E;c.preventDefault(),c.stopPropagation();const o=(E=c.dataTransfer)==null?void 0:E.files;o&&o.length&&bj(o)},Rj=()=>IM(exports,null,function*(){var c;return(c=j==null?void 0:j.data)!=null&&c.id?j:(qe.current||(qe.current=new Promise((o,E)=>{Re(!0),s==null||s({netOpen:u?Ue.OPEN:Ue.CLOSE}).then(v=>{var P,jM;g==null||g(v),Re(!1),n(!!((P=v.data)!=null&&P.netOpen)),rN(!!((jM=v.data)!=null&&jM.enableNetOpen)),xt(v),o(v)}).catch(v=>{qe.current=null,E(v)})})),qe.current)}),kD=c=>IM(exports,null,function*(){const o=yield Rj();return UD(o,c)}),UD=(c,o)=>{const E=Ai(o.name);return new Promise(v=>{var jM;const P={files:[`${sN.v4()}.${E}`],isv:"minio",knowledgeId:((jM=c.data)==null?void 0:jM.id)||"",type:1};b==null||b.postTicket(P).then(NM=>{b.uploadMinioFile(NM.minio,o).then(()=>{var qM,aM;const SM=(qM=NM.minio.endpoints)==null?void 0:qM[0],fM=NM.minio.bucket,iM=(aM=NM.minio.fileKeys)==null?void 0:aM[0];v(`${NM.minio.useSSL?"https:":location.protocol}//${SM}/${fM}/${iM}`)}).catch(()=>{})}).catch(()=>{})})},pD=()=>{const c=R.current;!c||!MM.current||c.scrollTo({top:c.scrollHeight})};z.useLayoutEffect(()=>{pD()},[I]),z.useEffect(()=>{const c=()=>{eM.current=!1;const o=R.current;(!o||o.scrollTop>-80)&&(Y.current=!1)};return window.addEventListener("pointerup",c),()=>window.removeEventListener("pointerup",c)},[]);const Wj=(c,o)=>new Promise(E=>{if(!o.file.url||!(N!=null&&N.id))return E();const v=_M(zM({},o.file),{type:1});b==null||b.postApplicationIdSessionKnowledgeSessionFile(N==null?void 0:N.id,c,v).finally(()=>{var P;(P=TN.current)==null||P.update().finally(E)})}),bD=()=>{var c;(c=j==null?void 0:j.data)!=null&&c.id&&(re(!1),j.suspend())},vD=c=>{const o=R.current;o&&(MM.current=!0,Y.current=!1,ot(!1),setTimeout(()=>{o.scrollTo({top:o.scrollHeight,behavior:c==null?void 0:c.behavior})},c==null?void 0:c.ms))},Zj=()=>{Y.current=!0},GD=c=>{var E;const o=(E=c.target)==null?void 0:E.closest(".bottom-right");o instanceof HTMLElement&&o.scrollHeight>o.clientHeight+1||(Zj(),requestAnimationFrame(()=>{const v=R.current;Y.current&&v&&v.scrollTop>-80&&(Y.current=!1)}))},PD=c=>{const o=c.currentTarget,{offsetX:E,offsetY:v}=c.nativeEvent;(E>o.clientWidth||v>o.clientHeight)&&(eM.current=!0,Zj())},RD=()=>{const c=R.current;if(!c)return;if(!(c.scrollTop<=-80)){MM.current=!0,Y.current=!1,ot(!1);return}(Y.current||eM.current)&&(MM.current=!1,Y.current=!1,ot(!0))},WD=xe.useMemoizedFn(c=>{var o,E;(o=bM.current)==null||o.update(c),(E=bM.current)==null||E.focus()}),ZD=xe.useMemoizedFn(c=>{Ot(c)}),_D=xe.useMemoizedFn(()=>{var o;if(!((o=j==null?void 0:j.data)!=null&&o.id))return;f.current=[...I.slice(1,I.length)],A(f.current);const c=new _e("",j.data.id,B.IHistoryRole.System);c.isWaiting=!0,f.current=[c,...f.current],A(f.current),Ce(!0),re(!0),j.answerAgain()});z.useEffect(()=>{var c,o;uM.current=(c=j==null?void 0:j.data)==null?void 0:c.id,!hj&&((o=At.current)==null||o.clear())},[j]);const BD=()=>{var E;if(!((E=j==null?void 0:j.data)!=null&&E.id))return;const o=I[I.length-1].messageTime;j.fetchMessages({endTime:o,pageSize:fi}).then(v=>{const P=v||[];if(!P||!(P!=null&&P.length)){aN(!1);return}P.length<10?aN(!1):aN(!0),A([...I,...P.reverse()])})},JD=c=>IM(exports,null,function*(){var o,E;if(!((o=j==null?void 0:j.data)!=null&&o.id))n(c);else{if(yield j.setNetOpen(c),!((E=j.data)!=null&&E.id))return;n(c)}}),wt=()=>IM(exports,null,function*(){j?j.fetchData().then(c=>{var o;(o=j==null?void 0:j.data)!=null&&o.id&&(n(c.netOpen),rN(c.enableNetOpen))}):(n(typeof(S==null?void 0:S.connectNetwork)=="object"&&typeof(S==null?void 0:S.connectNetwork.default)=="boolean"?S.connectNetwork.default:!1),rN(N.arrange[0].enableNetOpen))});z.useEffect(()=>{wt()},[j]),z.useEffect(()=>{let c=null,o=null;const E=()=>{var iM,qM;if(!R.current)return;const P=document.getElementById("chat-main"),jM=(iM=R.current)==null?void 0:iM.querySelector(".infinite-scroll-component__outerdiv"),NM=(qM=R.current)==null?void 0:qM.querySelector(".infinite-scroll-component");if(!jM||!NM||!P)return;const SM=P.offsetHeight;if(NM.offsetHeight<=SM){if(jM.style.height==="100%")return;jM.style.height="100%"}else{if(jM.style.height==="auto")return;jM.style.height="auto"}},v=()=>{var NM;if(typeof ResizeObserver=="undefined"||!R.current)return;const P=document.getElementById("chat-main"),jM=(NM=R.current)==null?void 0:NM.querySelector(".infinite-scroll-component");!jM||!P||(o=new ResizeObserver(()=>{E()}),o.observe(jM),o.observe(P))};return c=requestAnimationFrame(()=>{E(),v()}),()=>{c!==null&&cancelAnimationFrame(c),o==null||o.disconnect()}},[I]),z.useEffect(()=>{if(j)return;const c=()=>{const v=((p==null?void 0:p.promptVariables)||[]).filter(P=>P.type?!(P.type===B.PromptVariableType.User&&P.key==="query")&&!(P.type===B.PromptVariableType.System&&P.key==="datetime")&&P.status===1:P.key!=="query"&&P.status===1).map((P,jM)=>{var SM,fM;let NM="";return typeof(S==null?void 0:S.promptVariables)=="object"&&(NM=((fM=(SM=S.promptVariables.default)==null?void 0:SM.find(iM=>iM.key===P.key&&iM.type===P.type))==null?void 0:fM.value)||""),{id:jM+"",key:P.key,name:P.name,value:NM,type:P.type}});cN([...v].sort((P,jM)=>P.key.localeCompare(jM.key)))};return p!=null&&p.ready?c():p==null||p.addEventListener("ready",c),()=>{p==null||p.removeEventListener("ready",c)}},[j,p,S==null?void 0:S.promptVariables]);const _j=()=>s==null?void 0:s({netOpen:u?Ue.OPEN:Ue.CLOSE}).then(c=>{var o,E;return g==null||g(c),Re(!1),n(!!((o=c.data)!=null&&o.netOpen)),rN(!!((E=c.data)!=null&&E.enableNetOpen)),xt(c),c}),Bj=!!I.length,Jj=z.useMemo(()=>{var c;return N.arrange&&((c=N.arrange[0])!=null&&c.openingContent)?i.jsx(zs,{application:N,history:{role:1,content:N.arrange[0].openingContent,code:200,messageId:"opening-message",sessionId:"",reference:[],searchReference:[],messageTime:HM(Date.now()).format("YYYY-MM-DD HH:mm:ss"),actions:[],isLoading:!1},actions:Bj,markdown:S==null?void 0:S.markdown}):null},[N==null?void 0:N.arrange,Bj]);z.useImperativeHandle(e,()=>({getCurrentInputText:()=>{var c;return(c=bM.current)==null?void 0:c.getCurrentText()},send:c=>IM(exports,null,function*(){if(!(yield Ot(c)))throw new Error("send was blocked")})})),z.useEffect(()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;c&&nN(E=>_M(zM({},E),{[c]:[]}))},[(Xj=j==null?void 0:j.data)==null?void 0:Xj.id]);const Fj=!!CM&&(K==null?void 0:K.picker)!==!1;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`agent-chat${Fj?" with-workspace-tree":""}`,children:[Fj&&CM&&i.jsx(qg,{workspace:CM,disclosureText:K==null?void 0:K.disclosureText,disclosure:K==null?void 0:K.disclosure,getContainer:l,highlight:tM,disabled:TM}),i.jsxs("div",{className:"agent-chat-column",children:[xD?i.jsx("div",{className:"session-loading",children:i.jsx(a.Spin,{})}):i.jsxs(i.Fragment,{children:[(Q==null?void 0:Q.promptVariables)&&i.jsx(Ts,{ref:Yj,appId:N.id,currentSession:j,promptVariables:ue,setPromptVariables:cN,setCurrentSession:g}),i.jsxs("div",{className:"chat-main",id:"chat-main",style:ZM,children:[i.jsx("div",{className:"chat-main-wrapper",id:"scrollableDiv",style:{height:"100%",overflowY:"auto",display:"flex",flexDirection:"column-reverse"},ref:R,onScroll:RD,onWheel:GD,onPointerDown:PD,children:($j=j==null?void 0:j.data)!=null&&$j.id&&(I!=null&&I.length)?i.jsxs(qD,{dataLength:I.length,next:BD,style:{display:"flex",flexDirection:"column-reverse",overflowX:"hidden",overflowAnchor:"none"},inverse:!0,endMessage:I.length>fi&&((Kj=R.current)!=null&&Kj.scrollTop)&&((qj=R.current)==null?void 0:qj.scrollTop)<-10?i.jsx(a.Divider,{plain:!0,children:"没有更多数据了"}):null,hasMore:Qj,loader:i.jsx("div",{style:{height:"50px",textAlign:"center",overflow:"hidden"},children:i.jsx(a.Spin,{})}),scrollableTarget:"scrollableDiv",children:[I.map((c,o)=>i.jsx(nu,{application:N,currentSession:j,history:c,docViewerUrl:t,isLastHistory:o===0,onRelatedClick:ZD,onAgainClick:_D,onEditClick:WD,markdown:S==null?void 0:S.markdown},c.renderKey||`${c.messageId}-${o}`)),!Qj&&Jj]}):i.jsxs("div",{className:"main-empty",children:[(S==null?void 0:S.greeting)!==!1&&i.jsx(Cg,{text:S!=null&&S.greeting&&typeof S.greeting=="object"&&S.greeting.text!==void 0?S.greeting.text:(Mi=N.arrange)!=null&&Mi.length&&((ei=N.arrange[0])!=null&&ei.greetings)?N.arrange[0].greetings:mi.text,icon:S===void 0||S.greeting===!0||((Ni=S.greeting)==null?void 0:Ni.icon)===void 0?$||mi.icon:S.greeting.icon,children:!!pM.length&&(((S==null?void 0:S.greeting)===void 0||(S==null?void 0:S.greeting))===!0||typeof(S==null?void 0:S.greeting)=="object"&&S.greeting.questions!==!1)&&i.jsx(Is,{ref:At,sid:(ti=j==null?void 0:j.data)==null?void 0:ti.id,isRecommendClearing:KM,data:pM,layoutBreakpoints:typeof(S==null?void 0:S.greeting)=="object"?S.greeting.layoutBreakpoints:void 0,onItemClick:c=>{var E,v,P;if(h(c==null?void 0:c.question),$e(c==null?void 0:c.question),KM)return;c!=null&&c.id&&le(!0);const o=(E=j==null?void 0:j.data)==null?void 0:E.id;Q!=null&&Q.fileUpload?(P=(v=TN.current)==null?void 0:v.clear())==null||P.then(()=>{var jM,NM;c!=null&&c.id&&(o?(jM=Wj(o,c))==null||jM.finally(()=>{le(!1)}):(le(!1),Re(!0),(NM=_j())==null||NM.then(SM=>{var fM;(fM=Wj(SM.id,c))==null||fM.finally(()=>{le(!1)})})))}):o?le(!1):(le(!1),Re(!0),_j())}})}),Jj]})}),Ej&&i.jsx("div",{className:"session-stop",children:i.jsx(a.Button,{type:"primary",style:{background:"white"},ghost:!0,size:"small",icon:i.jsx(LM,{type:"icon-zantinghuida",style:{fontSize:16}}),onClick:()=>bD(),children:"停止回答"})}),lD&&(I==null?void 0:I.length)>0&&i.jsx("div",{className:"back-bottom",children:i.jsx(a.Button,{size:"small",onClick:()=>vD({behavior:"smooth"}),type:"link",icon:i.jsx(LM,{type:"icon-yijianhuidaodibu",style:{fontSize:24}})})})]}),i.jsx("div",{className:"chat-footer",children:i.jsxs("div",{className:"chat-footer-input",children:[cM.length>0&&i.jsx("div",{className:"input-files",children:cM.map((c,o)=>i.jsx(yg,{className:"thumb-40",file:c,actions:{upload:E=>IM(exports,null,function*(){UM(v=>v+1);try{return yield kD(E)}finally{UM(v=>Math.max(0,v-1))}}),remove:()=>{sM(E=>E.filter((v,P)=>P!==o)),YM(E=>E.filter((v,P)=>P!==o))}},onUrlChange:E=>{YM(v=>{const P=[...v];return P[o]=E,P})}},o))}),CM&&i.jsx(uu,{workspace:CM}),CM&&wM&&i.jsx(zu,{bridge:wM,getContainer:l}),i.jsxs("div",{className:"footer-upload-action-wrapper",children:[i.jsxs(a.Space,{className:"footer-upload-action",onClick:c=>c.preventDefault(),children:[i.jsxs(a.Space,{children:[(N.type===B.ApplicationTypes.Agent&&(Q==null?void 0:Q.imageUpload)||N.type===B.ApplicationTypes.Dialog&&((ji=N.arrange)==null?void 0:ji.length)&&!!N.arrange[0].visionOpen&&(Q==null?void 0:Q.imageUpload))&&i.jsx(a.Upload,{multiple:!0,disabled:cM.length>=Be||TM,accept:".jpg, .png, .jpeg,.bmp",listType:"picture-card",beforeUpload:pj,className:"footer-upload-picture",showUploadList:!1,children:cM.length<Be?i.jsx(a.Tooltip,{placement:"topLeft",overlayClassName:"footer-upload-tooltip",title:i.jsx("div",{children:`支持上传.jpg .png .jpeg
|
|
16
|
-
.bmp格式的图片数据,单文件最大${ft}M,最多${Be}张`}),children:i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:i.jsx(LM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}):i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},disabled:!0,icon:i.jsx(LM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),D&&(Q!=null&&Q.fileUpload)&&(N!=null&&N.id)?i.jsx(ns,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===B.ApplicationTypes.Agent,ref:TN,isFirstSession:hj,docViewerUrl:t,onStatusChange:c=>IM(exports,null,function*(){c!=="process"?(UN(!0),wt()):UN(!1)}),createSession:()=>Rj().then(c=>{var E;return((E=c.data)==null?void 0:E.id)||""}),sid:(ii=j==null?void 0:j.data)==null?void 0:ii.id,disabled:yt||TM,afterFileAdd:(c,o)=>{o&&nN(E=>{const v=E[o]||[];return{[o]:[...v,c]}})},afterFileDelete:c=>{var E;const o=(E=j==null?void 0:j.data)==null?void 0:E.id;o&&nN(v=>{const P=v[o]||[];return{[o]:P.filter(jM=>jM.id!==c)}})},onFileListChange:c=>{LD(c)},shouldContinue:yD,afterFilesClear:()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;c&&(nN({[c]:[]}),wt())}}):null,(Q==null?void 0:Q.prompt)&&(N==null?void 0:N.id)&&i.jsx(Rg,{appId:N.id,list:[],search:IN?nD:"",onPromptSelect:c=>{$e(c.context),h(c.context)},disabled:TM})]}),i.jsxs(a.Space,{children:[(Q==null?void 0:Q.connectNetwork)&&N.type===B.ApplicationTypes.Dialog&&((si=N.arrange)==null?void 0:si.length)&&!!N.arrange[0].enableNetOpen&&i.jsx(Ug,{sessionId:(Di=j==null?void 0:j.data)==null?void 0:Di.id,netStatus:u,enable:typeof(S==null?void 0:S.connectNetwork)=="object"&&typeof(S==null?void 0:S.connectNetwork.diabled)=="boolean"?!(S!=null&&S.connectNetwork.diabled):OD,disabledTip:j?void 0:"网络访问已被禁用",onNetStatusChange:c=>{JD(c)}}),(Q==null?void 0:Q.sessionList)&&i.jsx(Sg,{currentSessionId:(zi=j==null?void 0:j.data)==null?void 0:zi.id,onSessionChange:(c,o)=>{$e(void 0),vN(!0),g==null||g(o)},disabled:TM}),dM&&mM==="float"&&i.jsx("div",{className:"session-history-drawer-component",children:i.jsx(a.Popover,{placement:"topRight",showArrow:!1,overlayClassName:"session-history-overlay",overlayStyle:{padding:"4px"},getPopupContainer:c=>c.parentNode,content:"会话历史记录",children:i.jsx(a.Button,{className:"history-overlay-action",disabled:TM,type:"text",icon:i.jsx(LM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>fj(!0)})})}),(Q==null?void 0:Q.sessionOpen)&&i.jsx(a.Button,{icon:i.jsx(AM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:Ej||!j||!I.length||TM,onClick:()=>{var c,o;vN(!1),g==null||g(null),qe.current=null,n(!1),(c=Yj.current)==null||c.clear(),(o=At.current)==null||o.clear()},children:"新会话"})]})]}),!!lt&&i.jsx("div",{className:"remainingSeconds-mark"})]}),i.jsxs("div",{className:"footer-textarea",onPaste:vj,onPasteCapture:vj,onDrop:Pj,onDropCapture:Pj,onDragOver:Gj,onDragOverCapture:Gj,children:[i.jsx(us,{ref:bM,maxLength:Z,text:cD,networkStatus:!1,loading:Sj||bN,disabled:F||$M||TM||Sj||bN,onTextSend:Ot,onChange:(c,o)=>{$e(c);const E=o.getText().replace(/[\n\s]+$/,"");h(E),TD(E),IN||ID(!0)},clearAction:i.jsx(a.Space,{size:0,children:i.jsx(a.Button,{type:"link",disabled:yt||TM,ghost:!0,icon:i.jsx(LM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>QD()})})}),!!lt&&i.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",lt]})]})]})}),i.jsx(Og,{tips:J}),wj&&i.jsx(wg,{isvisible:wj,files:rD,sessionId:(gi=j==null?void 0:j.data)==null?void 0:gi.id,onClose:c=>{aD(!1),oD(!1)}})]}),mj&&i.jsx(kg,{currentSession:j,application:N,networkStatus:u,setCurrentSession:g,disabled:TM,isSessionHistoryVisible:mj,setIsSessionHistoryVisible:fj,onSessionChange:c=>{vN(!0)}})]})]}),dt&&GN&&r.length>0&&Ji.createPortal(i.jsxs("div",{className:"artifacts-dock",ref:Uj,children:[i.jsxs("div",{className:`artifacts-drawer${T?" is-open":""}`,children:[i.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>y(c=>!c),children:[i.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),T?i.jsx(AM.RightOutlined,{}):i.jsx(AM.LeftOutlined,{})]}),i.jsxs("div",{className:"artifacts-panel",children:[i.jsxs("div",{className:"artifacts-panel-main",children:[i.jsx("div",{className:"artifacts-panel-title",children:"产出物"}),i.jsx(Ig,{artifacts:r,activeArtifact:C,onPreview:O})]}),LN.preview==="column"&&C&&i.jsx(Ag,{artifact:C,style:LN.style,onClose:()=>O(null)})]})]}),i.jsx(Lg,{placement:LN.preview,artifact:C,style:LN.style,onClose:()=>O(null),getContainer:()=>Uj.current||dt})]}),dt)]})});const As=M=>{const{disabled:e,checkedValues:N,currKnowledgeList:t,selectCount:j,onSelectChange:s}=M,[D,g]=z.useState(!1),u=i.jsx(a.Checkbox.Group,{style:{width:"100%"},onChange:s,value:N,disabled:e,children:i.jsx(a.Row,{gutter:[20,12],children:t==null?void 0:t.map(I=>i.jsx(a.Col,{span:24,children:i.jsx(a.Checkbox,{value:I.id,children:I.name})},I.id))})}),n=I=>{g(I)};return i.jsx("div",{className:"knowledge-select",style:{borderColor:D?"#9C24F2":"#84868C"},children:i.jsx(a.Popover,{className:"select-popover",placement:"bottomRight",title:null,content:u,trigger:"click",overlayStyle:{width:280},onOpenChange:n,getPopupContainer:I=>I.parentNode,children:i.jsxs("div",{className:"",onClick:I=>I.preventDefault(),children:[i.jsx(LM,{className:"select-icon",type:"icon-open"}),i.jsx("span",{className:"title",children:"参考知识库"}),i.jsxs("span",{className:"content",children:["已选 ",j," 个"]})]})})})},au=M=>{var C,O;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:j,transform:s,features:D}=z.useContext(JM),[g,u]=z.useState([]),[n,I]=z.useState(typeof(D==null?void 0:D.knowledges)=="object"?((C=D.knowledges.default)==null?void 0:C.map(w=>w.id))||[]:[]),[A,r]=z.useState(0),[L,T]=z.useState(!1);z.useEffect(()=>{if(!(N!=null&&N.id))return;const w=N.arrange;if(!(w!=null&&w.length))return;const h=w[0].knowledges||[];u(h);const k=typeof(D==null?void 0:D.knowledges)=="object"&&D.knowledges.default||h;if(Array.isArray(k)&&k.some(Y=>Array.isArray(Y.fileIds)&&Y.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(qN(k||[])>be)throw Error(`knowledges and fileIds total count cannot exceed ${be}`);if(!e){I(k.map(MM=>MM.id)),r(k.length),t==null||t(k);return}const R=()=>{const MM=e.knowledges||k;r(MM.length);const Y=MM.map(eM=>eM.id);I(Y)};return R(),e.addEventListener("data:updated",R),()=>{e==null||e.removeEventListener("data:updated",R)}},[N,e]),z.useEffect(()=>{var m;if(!L||(T(!1),!(N!=null&&N.id)))return;const w=[];n==null||n.map(h=>{const k=g==null?void 0:g.find(W=>W.id===h);w.push(k)}),(m=e==null?void 0:e.data)!=null&&m.id&&e.setKnowledges(w)},[L]);const y=w=>{T(!0),I(w);const m=[];w==null||w.map(h=>{const k=g==null?void 0:g.find(W=>W.id===h);m.push(k)}),t==null||t(m),r(w.length)};return i.jsxs("div",{className:"chat-header",children:[i.jsxs(a.Space,{className:"header-title",children:[j==="inlay"&&((O=e==null?void 0:e.data)==null?void 0:O.name),j==="float"&&(N==null?void 0:N.name)]}),(s==null?void 0:s.knowledges)&&g.length!==0&&i.jsx(As,{disabled:typeof(D==null?void 0:D.knowledges)=="object"&&(D==null?void 0:D.knowledges.diabled)||!1,checkedValues:n,currKnowledgeList:g,selectCount:A,onSelectChange:y})]})};const ru=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:j}=M,[s,D]=z.useState(),{showHeader:g,agentClient:u,sider:n,onSessionLoad:I,features:A,mode:r}=z.useContext(JM),[L,T]=z.useState(),y=z.useRef(null),[C,O]=z.useState(""),[w,m]=z.useState(),h=z.useRef(null),[k,W]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:R}=Nj();z.useEffect(()=>{var Y;W(s?!!((Y=s.data)!=null&&Y.netOpen):typeof(A==null?void 0:A.connectNetwork)=="object"&&typeof(A==null?void 0:A.connectNetwork.default)=="boolean"?A.connectNetwork.default:!1)},[s]),z.useEffect(()=>{const Y=()=>IM(exports,null,function*(){const eM=u==null?void 0:u.application;if(!(eM!=null&&eM.id))return;const b=eM==null?void 0:eM.arrange;if(!(b!=null&&b.length))return;const G=b[0].embeddingService;O(G),T(eM)});if(u!=null&&u.ready){Y();return}return u==null||u.addEventListener("ready",()=>Y()),()=>{u==null||u.removeEventListener("ready",Y)}},[u]),z.useEffect(()=>{u&&N&&(u.ready?u==null||u.getSessions().then(Y=>IM(exports,null,function*(){D==null||D(Y.find(eM=>eM.id===N))})):u.addEventListener("ready",()=>IM(exports,null,function*(){u==null||u.getSessions().then(Y=>IM(exports,null,function*(){D==null||D(Y.find(eM=>eM.id===N))}))}),!0))},[u,N]),z.useEffect(()=>{if(!s){I&&I({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}s.data&&I&&I({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s}),s.addEventListener("data:loaded",()=>{s!=null&&s.data&&I&&I({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s})},!0)},[s]);const MM=Y=>{var eM;return(eM=y.current)==null?void 0:eM.create(_M(zM({},Y),{knowledges:w}))};return z.useImperativeHandle(e,()=>({createSession:Y=>MM(Y),getSessionList:()=>{var eM;const Y=((eM=y.current)==null?void 0:eM.list())||[];return Promise.resolve(Y)},getCurrentInputText:()=>{var Y;return(Y=h.current)==null?void 0:Y.getCurrentInputText()},send:Y=>{var eM;return(eM=h.current)!=null&&eM.send?h.current.send(Y):Promise.reject(new Error("send is not available"))}})),i.jsx("div",{className:"dialog",children:i.jsxs("div",{className:"dialog-pannel",children:[i.jsx("div",{className:"dialog-sider",style:{display:n&&r==="inlay"?"block":"none"},children:i.jsx(tj,{ref:y,appId:t,networkStatus:k,currentSession:s,application:L,setCurrentSession:D,checkKnowledges:w,setCheckKnowledges:g?m:void 0,sessionId:N,afterSessionClick:Y=>{var eM,b;((eM=Y.data)==null?void 0:eM.id)!==((b=s==null?void 0:s.data)==null?void 0:b.id)&&R(!0)}})}),i.jsx("div",{className:"dialog-content",children:i.jsxs("div",{className:"dialog-chat",children:[g&&i.jsx("div",{className:"dialog-chat-header",children:i.jsx(au,{setCheckKnowledges:m,application:L,currentSession:s})}),i.jsx("div",{className:"dialog-chat-content",children:(L==null?void 0:L.id)&&i.jsx(cu,{setNetworkStatus:W,networkStatus:k,application:L,currentSession:s,onCreateSession:MM,docViewerUrl:j,embeddingService:C,setCurrentSession:D,ref:h})})]})})]})})}),Lu=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:j,theme:s,icon:D,docViewerUrl:g,token:u,debug:n,env:I,plugins:A,mcp:r,footer:L,defaultInput:T,onComment:y,onSessionLoad:C,onSessionUnload:O,onMessage:w,beforeMessageSend:m,bodyStyle:h,apiUrl:k,sessionId:W,disabled:R,transform:MM,features:Y,stream:eM,agentClient:b,application:p}=M,G=z.useRef(null),[J,Q]=z.useState(!1),[gM,QM]=z.useState(),[oM,yM]=z.useState(j),[ZM,TM]=z.useState(M.open),S=z.useRef(null);z.useEffect(()=>{p&&(console.log("[AgentClientUI] token",b,p),QM(p.id))},[p]),a.ConfigProvider.config({theme:s}),z.useEffect(()=>{j&&yM(j)},[j]);const d=($,{element:dM,size:mM})=>{yM({width:Number(mM.width),height:mM.height})};return z.useImperativeHandle(e,()=>({createSession:$=>{var dM;return(dM=S.current)==null?void 0:dM.createSession($)},getSessionList:()=>{var $;return($=S.current)==null?void 0:$.getSessionList()},getCurrentInputText:()=>{var $;return($=S.current)==null?void 0:$.getCurrentInputText()},send:$=>{var dM;return(dM=S.current)!=null&&dM.send?S.current.send($):Promise.reject(new Error("send is not available"))}})),i.jsx(a.ConfigProvider,{locale:Hi,children:i.jsxs($i,{value:_M(zM({},M),{popupContainer:G,agentClient:b,footer:L,defaultInput:T,onComment:y,onSessionLoad:C,onSessionUnload:O,onMessage:w,beforeMessageSend:m,bodyStyle:h,disabled:R,transform:MM,features:Y}),children:[i.jsx(XD.Resizable,{height:(oM==null?void 0:oM.height)||"100%",width:(oM==null?void 0:oM.width)||"100%",maxConstraints:[document.body.clientWidth-45],minConstraints:[Number(j==null?void 0:j.minWidth)],onResize:d,handle:i.jsx("span",{className:"resize-handle-ew"}),resizeHandles:N=="float"?["w"]:[],children:i.jsxs("div",{id:"dialog-modal",className:`gbot-dialog-modal ${N} ${ZM?"opened":"closed"}`,style:_M(zM({},j),{width:N=="float"?oM==null?void 0:oM.width:j==null?void 0:j.width,height:N==="float"?oM==null?void 0:oM.height:j==null?void 0:j.height,maxHeight:"100vh"}),ref:G,children:[J?i.jsx("div",{className:"loading",children:i.jsx(a.Spin,{})}):gM&&b?i.jsx(mg,{children:i.jsx(ru,{ref:S,appId:gM,docViewerUrl:g,bodyStyle:h,sessionId:W})}):null,(t==null?void 0:t.visible)&&i.jsx(a.Button,{className:"trigger-btn close-btn",icon:i.jsx("img",{src:D}),onClick:()=>TM(!1)})]})}),(t==null?void 0:t.visible)&&!ZM&&i.jsx(a.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:i.jsx("img",{src:D}),onClick:()=>TM(!0)})]})})}),Au="@glodon-aiot/agent-cli-ui",yu="3.26.0-alpha.13",ou="./dist/es/index.mjs",lu="./dist/lib/index.js",Cu="./dist/src/index.d.ts",du={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},Ou=["dist"],xu="module",Yu="dist/src/index.d.ts",wu={dev:"vite",start:"vite",build:"tsc && node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build --mode prod && yarn build:cdn","build:pre":"tsc && node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build --mode prod","build:cdn":"tsc && vite build --mode prod --config ./vite.config.cdn.ts",preview:"vite preview",check:"yarn prettier --check .",write:"yarn prettier --write .",lint:"eslint --ext .tsx,.ts --fix ./example -c .eslintrc.js",storybook:"start-storybook -p 6006 -s public","build-storybook":"build-storybook -s public",docs:"start-storybook -p 6006",commit:"cz"},Eu={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.13","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.13","@glodon-aiot/react-components":"^3.26.0-alpha.13","@matejmazur/react-mathjax":"^0.1.10","@react-pdf-viewer/core":"^3.12.0","@react-pdf-viewer/default-layout":"^3.12.0","@react-pdf-viewer/locales":"^1.0.0","@react-pdf-viewer/toolbar":"^3.12.0",ahooks:"^3.8.5",antd:"^4.24.16",axios:"0.24.0",classnames:"^2.5.1","copy-to-clipboard":"^3.3.3",dayjs:"^1.11.13",lodash:"^4.17.21","pdfjs-dist":"^3.0.279","quill-delta":"^5.1.0",react:">=17.0.0 <19.0.0","react-dom":">=17.0.0 <19.0.0","react-infinite-scroll-component":"^6.1.0","react-quill-new":"^3.6.0","react-resizable":"^3.0.5",uuid:"^11.1.0"},hu={"@babel/core":"^7.20.12","@commitlint/cli":"^17.0.3","@commitlint/config-conventional":"^17.0.3","@rollup/plugin-babel":"^6.0.4","@rollup/plugin-commonjs":"^28.0.0","@rollup/plugin-typescript":"^11.1.6","@storybook/addon-actions":"6.3.6","@storybook/addon-essentials":"6.4.9","@storybook/addon-interactions":"^6.5.16","@storybook/addon-links":"6.3.5","@storybook/addon-postcss":"2.0.0","@storybook/builder-vite":"^0.4.0","@storybook/node-logger":"6.4.9","@storybook/react":"6.4.9","@storybook/testing-library":"^0.0.13","@types/lodash":"^4","@types/react":"^18","@types/react-dom":"^18","@typescript-eslint/eslint-plugin":"^5.35.1","@typescript-eslint/parser":"^5.35.1","@vitejs/plugin-react":"^3.1.0",antd:"^4.24.0","babel-loader":"^8.3.0","babel-plugin-import":"^1.13.8",commitizen:"^4.3.0","css-loader":"^6.7.3","cz-conventional-changelog":"^3.3.0","cz-customizable":"^7.0.0",eslint:"^8.0.1","eslint-config-prettier":"^8.5.0","eslint-config-standard-with-typescript":"^22.0.0","eslint-plugin-import":"^2.25.2","eslint-plugin-n":"^15.0.0","eslint-plugin-promise":"^6.0.0","eslint-plugin-react":"^7.31.0","eslint-plugin-storybook":"^0.6.10",husky:">=6",less:"^4.1.2","less-loader":"^11.1.0","lint-staged":">=10","postcss-loader":"^7.2.4",prettier:"2.7.1","require-from-string":"^2.0.2","rollup-plugin-visualizer":"^6.0.1","storybook-less-loader":"^0.1.0",typescript:"*",vite:"^4.1.1","vite-plugin-css-injected-by-js":"^3.5.0","vite-plugin-dts":"^4.3.0","vite-plugin-externalize-deps":"^0.9.0"},Qu=[">0.2%","not dead","not op_mini all"],Su=["last 1 chrome version","last 1 firefox version","last 1 safari version"],mu={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},fu={access:"public",registry:"https://registry.npmjs.org/"},ku={hooks:{"commit-msg":"validate-commit-msg"}},Uu={name:Au,version:yu,module:ou,main:lu,typings:Cu,exports:du,files:Ou,type:xu,types:Yu,scripts:wu,dependencies:Eu,devDependencies:hu,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:Qu,development:Su,config:mu,publishConfig:fu,husky:ku};var ys=(M=>(M.dev="https://aiot-dev.glodon.com/api/cvforcepd",M.test="https://aiot-dev.glodon.com/api/cvforce",M.prod="https://copilot.glodon.com/api/cvforce",M.local="http://localhost:3000/api/cvforcepd",M))(ys||{});//! moment.js
|
|
16
|
+
.bmp格式的图片数据,单文件最大${ft}M,最多${Be}张`}),children:i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},icon:i.jsx(LM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}):i.jsx(a.Button,{type:"text",className:"camera-out-btn",style:{width:"22px",position:"relative",bottom:"-2px"},disabled:!0,icon:i.jsx(LM,{type:"icon-shangchuantupian",className:"icon-tianjia",style:{fontSize:"22px"}})})}),D&&(Q!=null&&Q.fileUpload)&&(N!=null&&N.id)?i.jsx(ns,{appId:N==null?void 0:N.id,allowExcelAttachment:N.type===B.ApplicationTypes.Agent,ref:TN,isFirstSession:hj,docViewerUrl:t,onStatusChange:c=>IM(exports,null,function*(){c!=="process"?(UN(!0),wt()):UN(!1)}),createSession:()=>Rj().then(c=>{var E;return((E=c.data)==null?void 0:E.id)||""}),sid:(ii=j==null?void 0:j.data)==null?void 0:ii.id,disabled:yt||TM,afterFileAdd:(c,o)=>{o&&nN(E=>{const v=E[o]||[];return{[o]:[...v,c]}})},afterFileDelete:c=>{var E;const o=(E=j==null?void 0:j.data)==null?void 0:E.id;o&&nN(v=>{const P=v[o]||[];return{[o]:P.filter(jM=>jM.id!==c)}})},onFileListChange:c=>{LD(c)},shouldContinue:yD,afterFilesClear:()=>{var o;const c=(o=j==null?void 0:j.data)==null?void 0:o.id;c&&(nN({[c]:[]}),wt())}}):null,(Q==null?void 0:Q.prompt)&&(N==null?void 0:N.id)&&i.jsx(Rg,{appId:N.id,list:[],search:IN?nD:"",onPromptSelect:c=>{$e(c.context),h(c.context)},disabled:TM})]}),i.jsxs(a.Space,{children:[(Q==null?void 0:Q.connectNetwork)&&N.type===B.ApplicationTypes.Dialog&&((si=N.arrange)==null?void 0:si.length)&&!!N.arrange[0].enableNetOpen&&i.jsx(Ug,{sessionId:(Di=j==null?void 0:j.data)==null?void 0:Di.id,netStatus:u,enable:typeof(S==null?void 0:S.connectNetwork)=="object"&&typeof(S==null?void 0:S.connectNetwork.diabled)=="boolean"?!(S!=null&&S.connectNetwork.diabled):OD,disabledTip:j?void 0:"网络访问已被禁用",onNetStatusChange:c=>{JD(c)}}),(Q==null?void 0:Q.sessionList)&&i.jsx(Sg,{currentSessionId:(zi=j==null?void 0:j.data)==null?void 0:zi.id,onSessionChange:(c,o)=>{$e(void 0),vN(!0),g==null||g(o)},disabled:TM}),dM&&mM==="float"&&i.jsx("div",{className:"session-history-drawer-component",children:i.jsx(a.Popover,{placement:"topRight",showArrow:!1,overlayClassName:"session-history-overlay",overlayStyle:{padding:"4px"},getPopupContainer:c=>c.parentNode,content:"会话历史记录",children:i.jsx(a.Button,{className:"history-overlay-action",disabled:TM,type:"text",icon:i.jsx(LM,{type:"icon-lishijilu",style:{fontSize:24}}),onClick:()=>fj(!0)})})}),(Q==null?void 0:Q.sessionOpen)&&i.jsx(a.Button,{icon:i.jsx(AM.PlusOutlined,{}),className:"add-btn",type:"primary",disabled:Ej||!j||!I.length||TM,onClick:()=>{var c,o;vN(!1),g==null||g(null),qe.current=null,n(!1),(c=Yj.current)==null||c.clear(),(o=At.current)==null||o.clear()},children:"新会话"})]})]}),!!lt&&i.jsx("div",{className:"remainingSeconds-mark"})]}),i.jsxs("div",{className:"footer-textarea",onPaste:vj,onPasteCapture:vj,onDrop:Pj,onDropCapture:Pj,onDragOver:Gj,onDragOverCapture:Gj,children:[i.jsx(us,{ref:bM,maxLength:Z,text:cD,networkStatus:!1,loading:Sj||bN,disabled:F||$M||TM||Sj||bN,onTextSend:Ot,onChange:(c,o)=>{$e(c);const E=o.getText().replace(/[\n\s]+$/,"");h(E),TD(E),IN||ID(!0)},clearAction:i.jsx(a.Space,{size:0,children:i.jsx(a.Button,{type:"link",disabled:yt||TM,ghost:!0,icon:i.jsx(LM,{style:{fontSize:22},type:"icon-qingchujiyi"}),onClick:()=>QD()})})}),!!lt&&i.jsxs("div",{className:"remainingSeconds-time",children:["您之前对话触发敏感词拦截,当前处于禁言状态,暂时无法发送消息,剩余禁言时长",lt]})]})]})}),i.jsx(Og,{tips:J}),wj&&i.jsx(wg,{isvisible:wj,files:rD,sessionId:(gi=j==null?void 0:j.data)==null?void 0:gi.id,onClose:c=>{aD(!1),oD(!1)}})]}),mj&&i.jsx(kg,{currentSession:j,application:N,networkStatus:u,setCurrentSession:g,disabled:TM,isSessionHistoryVisible:mj,setIsSessionHistoryVisible:fj,onSessionChange:c=>{vN(!0)}})]})]}),dt&&GN&&r.length>0&&Ji.createPortal(i.jsxs("div",{className:"artifacts-dock",ref:Uj,children:[i.jsxs("div",{className:`artifacts-drawer${T?" is-open":""}`,children:[i.jsxs("button",{type:"button",className:"artifacts-handle",onClick:()=>y(c=>!c),children:[i.jsx("span",{className:"artifacts-handle-text",children:"产出物"}),T?i.jsx(AM.RightOutlined,{}):i.jsx(AM.LeftOutlined,{})]}),i.jsxs("div",{className:"artifacts-panel",children:[i.jsxs("div",{className:"artifacts-panel-main",children:[i.jsx("div",{className:"artifacts-panel-title",children:"产出物"}),i.jsx(Ig,{artifacts:r,activeArtifact:C,onPreview:O})]}),LN.preview==="column"&&C&&i.jsx(Ag,{artifact:C,style:LN.style,onClose:()=>O(null)})]})]}),i.jsx(Lg,{placement:LN.preview,artifact:C,style:LN.style,onClose:()=>O(null),getContainer:()=>Uj.current||dt})]}),dt)]})});const As=M=>{const{disabled:e,checkedValues:N,currKnowledgeList:t,selectCount:j,onSelectChange:s}=M,[D,g]=z.useState(!1),u=i.jsx(a.Checkbox.Group,{style:{width:"100%"},onChange:s,value:N,disabled:e,children:i.jsx(a.Row,{gutter:[20,12],children:t==null?void 0:t.map(I=>i.jsx(a.Col,{span:24,children:i.jsx(a.Checkbox,{value:I.id,children:I.name})},I.id))})}),n=I=>{g(I)};return i.jsx("div",{className:"knowledge-select",style:{borderColor:D?"#9C24F2":"#84868C"},children:i.jsx(a.Popover,{className:"select-popover",placement:"bottomRight",title:null,content:u,trigger:"click",overlayStyle:{width:280},onOpenChange:n,getPopupContainer:I=>I.parentNode,children:i.jsxs("div",{className:"",onClick:I=>I.preventDefault(),children:[i.jsx(LM,{className:"select-icon",type:"icon-open"}),i.jsx("span",{className:"title",children:"参考知识库"}),i.jsxs("span",{className:"content",children:["已选 ",j," 个"]})]})})})},au=M=>{var C,O;const{currentSession:e,application:N,setCheckKnowledges:t}=M,{mode:j,transform:s,features:D}=z.useContext(JM),[g,u]=z.useState([]),[n,I]=z.useState(typeof(D==null?void 0:D.knowledges)=="object"?((C=D.knowledges.default)==null?void 0:C.map(w=>w.id))||[]:[]),[A,r]=z.useState(0),[L,T]=z.useState(!1);z.useEffect(()=>{if(!(N!=null&&N.id))return;const w=N.arrange;if(!(w!=null&&w.length))return;const h=w[0].knowledges||[];u(h);const k=typeof(D==null?void 0:D.knowledges)=="object"&&D.knowledges.default||h;if(Array.isArray(k)&&k.some(Y=>Array.isArray(Y.fileIds)&&Y.fileIds.length===0))throw Error("fileIds cannot be an empty array");if(qN(k||[])>be)throw Error(`knowledges and fileIds total count cannot exceed ${be}`);if(!e){I(k.map(MM=>MM.id)),r(k.length),t==null||t(k);return}const R=()=>{const MM=e.knowledges||k;r(MM.length);const Y=MM.map(eM=>eM.id);I(Y)};return R(),e.addEventListener("data:updated",R),()=>{e==null||e.removeEventListener("data:updated",R)}},[N,e]),z.useEffect(()=>{var m;if(!L||(T(!1),!(N!=null&&N.id)))return;const w=[];n==null||n.map(h=>{const k=g==null?void 0:g.find(W=>W.id===h);w.push(k)}),(m=e==null?void 0:e.data)!=null&&m.id&&e.setKnowledges(w)},[L]);const y=w=>{T(!0),I(w);const m=[];w==null||w.map(h=>{const k=g==null?void 0:g.find(W=>W.id===h);m.push(k)}),t==null||t(m),r(w.length)};return i.jsxs("div",{className:"chat-header",children:[i.jsxs(a.Space,{className:"header-title",children:[j==="inlay"&&((O=e==null?void 0:e.data)==null?void 0:O.name),j==="float"&&(N==null?void 0:N.name)]}),(s==null?void 0:s.knowledges)&&g.length!==0&&i.jsx(As,{disabled:typeof(D==null?void 0:D.knowledges)=="object"&&(D==null?void 0:D.knowledges.diabled)||!1,checkedValues:n,currKnowledgeList:g,selectCount:A,onSelectChange:y})]})};const ru=z.forwardRef((M,e)=>{const{sessionId:N,appId:t,docViewerUrl:j}=M,[s,D]=z.useState(),{showHeader:g,agentClient:u,sider:n,onSessionLoad:I,features:A,mode:r}=z.useContext(JM),[L,T]=z.useState(),y=z.useRef(null),[C,O]=z.useState(""),[w,m]=z.useState(),h=z.useRef(null),[k,W]=z.useState(!1);z.useState([]);const{setIsSwitchingToExistingSession:R}=Nj();z.useEffect(()=>{var Y;W(s?!!((Y=s.data)!=null&&Y.netOpen):typeof(A==null?void 0:A.connectNetwork)=="object"&&typeof(A==null?void 0:A.connectNetwork.default)=="boolean"?A.connectNetwork.default:!1)},[s]),z.useEffect(()=>{const Y=()=>IM(exports,null,function*(){const eM=u==null?void 0:u.application;if(!(eM!=null&&eM.id))return;const b=eM==null?void 0:eM.arrange;if(!(b!=null&&b.length))return;const G=b[0].embeddingService;O(G),T(eM)});if(u!=null&&u.ready){Y();return}return u==null||u.addEventListener("ready",()=>Y()),()=>{u==null||u.removeEventListener("ready",Y)}},[u]),z.useEffect(()=>{u&&N&&(u.ready?u==null||u.getSessions().then(Y=>IM(exports,null,function*(){D==null||D(Y.find(eM=>eM.id===N))})):u.addEventListener("ready",()=>IM(exports,null,function*(){u==null||u.getSessions().then(Y=>IM(exports,null,function*(){D==null||D(Y.find(eM=>eM.id===N))}))}),!0))},[u,N]),z.useEffect(()=>{if(!s){I&&I({applicationId:t,sessionId:"",session:null,sessionInstance:null});return}s.data&&I&&I({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s}),s.addEventListener("data:loaded",()=>{s!=null&&s.data&&I&&I({applicationId:t,sessionId:s.data.id,session:s.data,sessionInstance:s})},!0)},[s]);const MM=Y=>{var eM;return(eM=y.current)==null?void 0:eM.create(_M(zM({},Y),{knowledges:w}))};return z.useImperativeHandle(e,()=>({createSession:Y=>MM(Y),getSessionList:()=>{var eM;const Y=((eM=y.current)==null?void 0:eM.list())||[];return Promise.resolve(Y)},getCurrentInputText:()=>{var Y;return(Y=h.current)==null?void 0:Y.getCurrentInputText()},send:Y=>{var eM;return(eM=h.current)!=null&&eM.send?h.current.send(Y):Promise.reject(new Error("send is not available"))}})),i.jsx("div",{className:"dialog",children:i.jsxs("div",{className:"dialog-pannel",children:[i.jsx("div",{className:"dialog-sider",style:{display:n&&r==="inlay"?"block":"none"},children:i.jsx(tj,{ref:y,appId:t,networkStatus:k,currentSession:s,application:L,setCurrentSession:D,checkKnowledges:w,setCheckKnowledges:g?m:void 0,sessionId:N,afterSessionClick:Y=>{var eM,b;((eM=Y.data)==null?void 0:eM.id)!==((b=s==null?void 0:s.data)==null?void 0:b.id)&&R(!0)}})}),i.jsx("div",{className:"dialog-content",children:i.jsxs("div",{className:"dialog-chat",children:[g&&i.jsx("div",{className:"dialog-chat-header",children:i.jsx(au,{setCheckKnowledges:m,application:L,currentSession:s})}),i.jsx("div",{className:"dialog-chat-content",children:(L==null?void 0:L.id)&&i.jsx(cu,{setNetworkStatus:W,networkStatus:k,application:L,currentSession:s,onCreateSession:MM,docViewerUrl:j,embeddingService:C,setCurrentSession:D,ref:h})})]})})]})})}),Lu=z.forwardRef((M,e)=>{const{className:N,triggerButton:t,size:j,theme:s,icon:D,docViewerUrl:g,token:u,debug:n,env:I,plugins:A,mcp:r,footer:L,defaultInput:T,onComment:y,onSessionLoad:C,onSessionUnload:O,onMessage:w,beforeMessageSend:m,bodyStyle:h,apiUrl:k,sessionId:W,disabled:R,transform:MM,features:Y,stream:eM,agentClient:b,application:p}=M,G=z.useRef(null),[J,Q]=z.useState(!1),[gM,QM]=z.useState(),[oM,yM]=z.useState(j),[ZM,TM]=z.useState(M.open),S=z.useRef(null);z.useEffect(()=>{p&&(console.log("[AgentClientUI] token",b,p),QM(p.id))},[p]),a.ConfigProvider.config({theme:s}),z.useEffect(()=>{j&&yM(j)},[j]);const d=($,{element:dM,size:mM})=>{yM({width:Number(mM.width),height:mM.height})};return z.useImperativeHandle(e,()=>({createSession:$=>{var dM;return(dM=S.current)==null?void 0:dM.createSession($)},getSessionList:()=>{var $;return($=S.current)==null?void 0:$.getSessionList()},getCurrentInputText:()=>{var $;return($=S.current)==null?void 0:$.getCurrentInputText()},send:$=>{var dM;return(dM=S.current)!=null&&dM.send?S.current.send($):Promise.reject(new Error("send is not available"))}})),i.jsx(a.ConfigProvider,{locale:Hi,children:i.jsxs($i,{value:_M(zM({},M),{popupContainer:G,agentClient:b,footer:L,defaultInput:T,onComment:y,onSessionLoad:C,onSessionUnload:O,onMessage:w,beforeMessageSend:m,bodyStyle:h,disabled:R,transform:MM,features:Y}),children:[i.jsx(XD.Resizable,{height:(oM==null?void 0:oM.height)||"100%",width:(oM==null?void 0:oM.width)||"100%",maxConstraints:[document.body.clientWidth-45],minConstraints:[Number(j==null?void 0:j.minWidth)],onResize:d,handle:i.jsx("span",{className:"resize-handle-ew"}),resizeHandles:N=="float"?["w"]:[],children:i.jsxs("div",{id:"dialog-modal",className:`gbot-dialog-modal ${N} ${ZM?"opened":"closed"}`,style:_M(zM({},j),{width:N=="float"?oM==null?void 0:oM.width:j==null?void 0:j.width,height:N==="float"?oM==null?void 0:oM.height:j==null?void 0:j.height,maxHeight:"100vh"}),ref:G,children:[J?i.jsx("div",{className:"loading",children:i.jsx(a.Spin,{})}):gM&&b?i.jsx(mg,{children:i.jsx(ru,{ref:S,appId:gM,docViewerUrl:g,bodyStyle:h,sessionId:W})}):null,(t==null?void 0:t.visible)&&i.jsx(a.Button,{className:"trigger-btn close-btn",icon:i.jsx("img",{src:D}),onClick:()=>TM(!1)})]})}),(t==null?void 0:t.visible)&&!ZM&&i.jsx(a.Button,{className:`${N}-trigger-btn open-btn`,style:t.style,icon:i.jsx("img",{src:D}),onClick:()=>TM(!0)})]})})}),Au="@glodon-aiot/agent-cli-ui",yu="3.26.0-alpha.14",ou="./dist/es/index.mjs",lu="./dist/lib/index.js",Cu="./dist/src/index.d.ts",du={import:"./dist/es/index.mjs",require:"./dist/lib/index.js",types:"./dist/src/index.d.ts"},Ou=["dist"],xu="module",Yu="dist/src/index.d.ts",wu={dev:"vite",start:"vite",build:"tsc && node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build --mode prod && yarn build:cdn","build:pre":"tsc && node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build --mode prod","build:cdn":"tsc && vite build --mode prod --config ./vite.config.cdn.ts",preview:"vite preview",check:"yarn prettier --check .",write:"yarn prettier --write .",lint:"eslint --ext .tsx,.ts --fix ./example -c .eslintrc.js",storybook:"start-storybook -p 6006 -s public","build-storybook":"build-storybook -s public",docs:"start-storybook -p 6006",commit:"cz"},Eu={"@ant-design/icons":"^5.3.4","@glodon-aiot/apis":"^3.26.0-alpha.14","@glodon-aiot/bot-client-sdk":"^3.26.0-alpha.14","@glodon-aiot/react-components":"^3.26.0-alpha.14","@matejmazur/react-mathjax":"^0.1.10","@react-pdf-viewer/core":"^3.12.0","@react-pdf-viewer/default-layout":"^3.12.0","@react-pdf-viewer/locales":"^1.0.0","@react-pdf-viewer/toolbar":"^3.12.0",ahooks:"^3.8.5",antd:"^4.24.16",axios:"0.24.0",classnames:"^2.5.1","copy-to-clipboard":"^3.3.3",dayjs:"^1.11.13",lodash:"^4.17.21","pdfjs-dist":"^3.0.279","quill-delta":"^5.1.0",react:">=17.0.0 <19.0.0","react-dom":">=17.0.0 <19.0.0","react-infinite-scroll-component":"^6.1.0","react-quill-new":"^3.6.0","react-resizable":"^3.0.5",uuid:"^11.1.0"},hu={"@babel/core":"^7.20.12","@commitlint/cli":"^17.0.3","@commitlint/config-conventional":"^17.0.3","@rollup/plugin-babel":"^6.0.4","@rollup/plugin-commonjs":"^28.0.0","@rollup/plugin-typescript":"^11.1.6","@storybook/addon-actions":"6.3.6","@storybook/addon-essentials":"6.4.9","@storybook/addon-interactions":"^6.5.16","@storybook/addon-links":"6.3.5","@storybook/addon-postcss":"2.0.0","@storybook/builder-vite":"^0.4.0","@storybook/node-logger":"6.4.9","@storybook/react":"6.4.9","@storybook/testing-library":"^0.0.13","@types/lodash":"^4","@types/react":"^18","@types/react-dom":"^18","@typescript-eslint/eslint-plugin":"^5.35.1","@typescript-eslint/parser":"^5.35.1","@vitejs/plugin-react":"^3.1.0",antd:"^4.24.0","babel-loader":"^8.3.0","babel-plugin-import":"^1.13.8",commitizen:"^4.3.0","css-loader":"^6.7.3","cz-conventional-changelog":"^3.3.0","cz-customizable":"^7.0.0",eslint:"^8.0.1","eslint-config-prettier":"^8.5.0","eslint-config-standard-with-typescript":"^22.0.0","eslint-plugin-import":"^2.25.2","eslint-plugin-n":"^15.0.0","eslint-plugin-promise":"^6.0.0","eslint-plugin-react":"^7.31.0","eslint-plugin-storybook":"^0.6.10",husky:">=6",less:"^4.1.2","less-loader":"^11.1.0","lint-staged":">=10","postcss-loader":"^7.2.4",prettier:"2.7.1","require-from-string":"^2.0.2","rollup-plugin-visualizer":"^6.0.1","storybook-less-loader":"^0.1.0",typescript:"*",vite:"^4.1.1","vite-plugin-css-injected-by-js":"^3.5.0","vite-plugin-dts":"^4.3.0","vite-plugin-externalize-deps":"^0.9.0"},Qu=[">0.2%","not dead","not op_mini all"],Su=["last 1 chrome version","last 1 firefox version","last 1 safari version"],mu={commitizen:{path:"node_modules/cz-customizable"},"cz-customizable":{config:".cz-config.cjs"}},fu={access:"public",registry:"https://registry.npmjs.org/"},ku={hooks:{"commit-msg":"validate-commit-msg"}},Uu={name:Au,version:yu,module:ou,main:lu,typings:Cu,exports:du,files:Ou,type:xu,types:Yu,scripts:wu,dependencies:Eu,devDependencies:hu,"lint-staged":{"*.{js,css,md,jsx,less,ts,tsx,json}":"prettier --write"},production:Qu,development:Su,config:mu,publishConfig:fu,husky:ku};var ys=(M=>(M.dev="https://aiot-dev.glodon.com/api/cvforcepd",M.test="https://aiot-dev.glodon.com/api/cvforce",M.prod="https://copilot.glodon.com/api/cvforce",M.local="http://localhost:3000/api/cvforcepd",M))(ys||{});//! moment.js
|
|
17
17
|
//! version : 2.30.1
|
|
18
18
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
|
19
19
|
//! license : MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glodon-aiot/agent-cli-ui",
|
|
3
|
-
"version": "3.26.0-alpha.
|
|
3
|
+
"version": "3.26.0-alpha.14",
|
|
4
4
|
"module": "./dist/es/index.mjs",
|
|
5
5
|
"main": "./dist/lib/index.js",
|
|
6
6
|
"typings": "./dist/src/index.d.ts",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@ant-design/icons": "^5.3.4",
|
|
34
|
-
"@glodon-aiot/apis": "^3.26.0-alpha.
|
|
35
|
-
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.
|
|
36
|
-
"@glodon-aiot/react-components": "^3.26.0-alpha.
|
|
34
|
+
"@glodon-aiot/apis": "^3.26.0-alpha.14",
|
|
35
|
+
"@glodon-aiot/bot-client-sdk": "^3.26.0-alpha.14",
|
|
36
|
+
"@glodon-aiot/react-components": "^3.26.0-alpha.14",
|
|
37
37
|
"@matejmazur/react-mathjax": "^0.1.10",
|
|
38
38
|
"@react-pdf-viewer/core": "^3.12.0",
|
|
39
39
|
"@react-pdf-viewer/default-layout": "^3.12.0",
|